import request from '@/utils/request'

// 查询排课任务列表
export function listScheduleTask(query) {
  return request({
    url: '/academic/scheduleTask/list',
    method: 'get',
    params: query
  })
}

// 查询排课任务详细
export function getScheduleTask(id) {
  return request({
    url: '/academic/scheduleTask/' + id,
    method: 'get'
  })
}

// 新增排课任务
export function addScheduleTask(data) {
  return request({
    url: '/academic/scheduleTask',
    method: 'post',
    data: data
  })
}

// 修改排课任务
export function updateScheduleTask(data) {
  return request({
    url: '/academic/scheduleTask',
    method: 'put',
    data: data
  })
}

// 删除排课任务
export function delScheduleTask(id) {
  return request({
    url: '/academic/scheduleTask/' + id,
    method: 'delete'
  })
}

// 导出排课任务
export function exportScheduleTask(query) {
  return request({
    url: '/academic/scheduleTask/export',
    method: 'post',
    data: query,
    responseType: 'blob'
  })
}

// 开始排课任务
export function startScheduleTask(id) {
  return request({
    url: '/academic/scheduleTask/start/' + id,
    method: 'post'
  })
}

// 完成排课任务
export function completeScheduleTask(id) {
  return request({
    url: '/academic/scheduleTask/complete/' + id,
    method: 'post'
  })
}

// 更新任务状态
export function updateTaskStatus(id, status) {
  return request({
    url: '/academic/scheduleTask/status',
    method: 'put',
    data: { id, status }
  })
}

// 更新任务进度
export function updateTaskProgress(id, progress) {
  return request({
    url: '/academic/scheduleTask/progress',
    method: 'put',
    data: { id, progress }
  })
}

// 根据学期ID获取排课任务
export function getScheduleTaskBySemester(semesterId) {
  return request({
    url: '/academic/scheduleTask/semester/' + semesterId,
    method: 'get'
  })
}

// 智能排课
export function intelligentSchedule(semesterId) {
  return request({
    url: '/academic/scheduleTask/intelligent/' + semesterId,
    method: 'post'
  })
}